package ZoneId_Demo;

import java.util.ArrayList;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        while (true){
            System.out.println("请输入一个数");
            String strNum = sc.nextLine();
            int num = Integer.parseInt(strNum);
            if(num < 0 || num > 100){
                System.out.println("数据不在0-100中");
                continue;
            }
            list.add(num);
            int sum = getSum(list);
            if(sum >= 200){
                System.out.println("集合中的所有数据的和已经大于200了");
                break;
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    private static int getSum(ArrayList<Integer> list) {
        int sum = 0;
        for (int i = 0; i < list.size(); i++) {
            int num = list.get(i);
            sum += num;
        }
        return sum;
    }
}
